/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cadi.games;

import com.cadi.aux.Clickable;
import com.cadi.aux.Selector;
import com.cadi.menu.MainMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;

/**
 *
 * @author Luis Eduardo Garay
 */
public class BillSelector extends Selector{
    
    private JLabel background;
    public BillSelector(boolean condition){
        super();
        if (condition){
            voicefirst();
        }
        toMenu.setVisible(true);
        currentLevel = 1;
        toNextLevel = new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent evt){
                switch(currentLevel){
                    case 1:
                        setLevelTwoEasy();
                        currentLevel++;
                        break;
                    case 2:
                        setLevelThreeEasy();
                        currentLevel++;
                        break;
                    case 3:
                        setLevelFourEasy();
                        currentLevel++;
                        break;
                    case 4:
                        setLevelFiveEasy();
                        currentLevel++;
                        break;
                    case 5:
                        MainMenu main = new MainMenu();
                        window.setVisible(false);
                        break;
                    case 11:
                        setLevelTwoHard();
                        currentLevel++;
                        break;
                    case 12:
                        setLevelThreeHard();
                        currentLevel++;
                        break;
                    case 13:
                        setLevelFourHard();
                        currentLevel++;
                        break;
                    case 14:
                        setLevelFiveHard();
                        currentLevel++;
                        break;
                    case 15: 
                        MainMenu main2 = new MainMenu();
                        window.setVisible(false);
                        break;
                        
                }
                
            }};
        instructions = new JLabel(new ImageIcon(getClass().getResource("/resources/bill_instruction.png")));
        instructions.setBounds(150, 300, 200, 162);
        container.add(instructions, JLayeredPane.PALETTE_LAYER);
        bottomLeftObject = new Clickable(new ImageIcon(getClass().getResource("/resources/billete20.jpeg")));
        bottomLeftObject.setBounds( 500,400,303 , 167);
        container.add(bottomLeftObject, JLayeredPane.PALETTE_LAYER);
        bottomLeftObject.setGoal(true);
        bottomLeftObject.addMouseListener(toNextLevel);
        bottomRightObject = new Clickable(new ImageIcon(getClass().getResource("/resources/receipt.jpeg")));
        bottomRightObject.setBounds(900,400, 203, 116);
        container.add(bottomRightObject, JLayeredPane.PALETTE_LAYER);
        topRightObject = new Clickable(new ImageIcon(getClass().getResource("/resources/letter.jpg")));
        topRightObject.setBounds(600,150, 300, 174);
        container.add(topRightObject, JLayeredPane.PALETTE_LAYER);
        topLeftObject = new Clickable(new ImageIcon(getClass().getResource("/resources/ticket.png")));
        topLeftObject.setBounds(100, 30,430,239);
        container.add(topLeftObject, JLayeredPane.PALETTE_LAYER);
        background = new JLabel(new ImageIcon(getClass().getResource("/resources/fondo3.png")));
        background.setBounds(0, 0, 1280,800);
        container.add(background, JLayeredPane.PALETTE_LAYER);
        this.window.setVisible(true);
    }
    
    protected void setLevelTwoEasy(){
        bottomLeftObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/ticket2.jpg")));
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/ticket3.jpg")));
        bottomRightObject.setBounds(700,400, 400, 222);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete200.jpg")));
        topLeftObject.setGoal(true);
        topLeftObject.addMouseListener(toNextLevel);
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/letter.jpg")));
        bottomLeftObject.setBounds( 300,400,303 , 167);
        window.repaint();
        voice.play();
    }
    
    protected void setLevelThreeEasy(){
        topLeftObject.removeMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/ticket2.jpg")));
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete100.jpg")));
        topRightObject.setGoal(true);
        topRightObject.addMouseListener(toNextLevel);
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/receipt.jpeg")));
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/letter.jpg")));
        window.repaint();
        voice.play();
        
    }
    
    protected void setLevelFourEasy(){
        topRightObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/receipt.jpeg")));
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete50.jpg")));
        bottomRightObject.setGoal(true);
        bottomRightObject.addMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/letter.jpg")));
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/ticket.png")));
        window.repaint();
        voice.play();
    }
    
    protected void setLevelFiveEasy(){
        bottomRightObject.removeMouseListener(toNextLevel);
        bottomRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/ticket.png")));
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete500.jpeg")));
        topLeftObject.setGoal(true);
        topLeftObject.addMouseListener(toNextLevel);
        bottomLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/ticket2.jpg")));
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/letter.jpg")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelOneHard(){
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/seleccionaBilleteMex.wav"));
        voice.play();
        instructions.setIcon(new ImageIcon(getClass().getResource("/resources/bill_instruction_hard.png")));
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/20euros.jpg")));
        topRightObject.setBounds(720, 250, 300, 224);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete20.jpeg")));
        topLeftObject.setBounds(400, 250, 300, 230);
        topLeftObject.addMouseListener(toNextLevel);
        topLeftObject.setGoal(true);
        bottomLeftObject.setIcon(null);
        bottomRightObject.setIcon(null);
        currentLevel = 11;
        window.repaint();
    }
    
     public void setLevelTwoHard(){
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete50.jpg")));
        topRightObject.addMouseListener(toNextLevel);
        topRightObject.setGoal(true);
        topLeftObject.removeMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/50euros.jpeg")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelThreeHard(){
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete100.jpg")));
        topRightObject.setGoal(true);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/100Kroner.jpg")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelFourHard(){
        topRightObject.removeMouseListener(toNextLevel);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/200soles.jpg")));
        topLeftObject.addMouseListener(toNextLevel);
        topLeftObject.setGoal(true);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete200.jpg")));
        window.repaint();
        voice.play();
    }
    
    public void setLevelFiveHard(){
        topLeftObject.removeMouseListener(toNextLevel);
        topLeftObject.setIcon(new ImageIcon(getClass().getResource("/resources/500euros.jpg")));
        topRightObject.addMouseListener(toNextLevel);
        topRightObject.setGoal(true);
        topRightObject.setIcon(new ImageIcon(getClass().getResource("/resources/billete500.jpeg")));
        window.repaint();
        voice.play();
    }

    private void voicefirst() {
        voice = java.applet.Applet.newAudioClip(getClass().getResource("/resources/seleccionaBillete.wav"));
        voice.play();
    }
}
